<!DOCTYPE HTML>
<html>
<head>
 <link type="text/css" rel="stylesheet" href="css/bootstrap.css"/>
</head>
 <link type="text/css" rel="stylesheet" href="css/bootstrap.css"/>
<title>Jajanan Ngalam</title>
  
<body>

<body style="background-image:url(YellowBackground.bmp)" >
<h3><center>DAFTAR PRODUK</center></h3>
<a><center>
<?php

	mysql_connect("localhost","root","");
	mysql_select_db("ngalam");
	
	$dataPerPage = 5;
	$query   = "SELECT COUNT(*) AS nama FROM produk";
	$hasil1  = mysql_query($query);
	$data1   = mysql_fetch_array($hasil1);

	$Nama = $data1['nama'];
	// menentukan jumlah halaman yang muncul berdasarkan jumlah semua data

	$jumPage = ceil($Nama/$dataPerPage);

// menampilkan link previous

			if ($noPage > 1) echo  "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage-1)."'>&lt;&lt; Prev</a>";

			// memunculkan nomor halaman dan linknya

			for($page = 1; $page <= $jumPage; $page++)
			{
					 if ((($page >= $noPage - 3) && ($page <= $noPage + 3)) || ($page == 1) || ($page == $jumPage)) 
					 {   
						if (($showPage == 1) && ($page != 2))  echo "..."; 
						if (($showPage != ($jumPage - 1)) && ($page == $jumPage))  echo "...";
						if ($page == $noPage) echo " <b>".$page."</b> ";
						else echo " <a href='".$_SERVER['PHP_SELF']."?page=".$page."'>".$page."</a> ";
						$showPage = $page;          
					 }
			}

			// menampilkan link next

			if ($noPage < $jumPage) echo "<a href='".$_SERVER['PHP_SELF']."?page=".($noPage+1)."'>Next &gt;&gt;</a>";

?>
</center>
</a>

<table align="center" class="tabel table-condensed "  width="900" border="10" cellpadding="5" cellspacing="1" background="magenta" >
 <tr class="success">
    <th>Nama_Produk</th>
	<th>Deskripsi</th>
	<th>Gambar</th>	
 </tr>

<?php

  mysql_connect("localhost","root","");
  mysql_select_db("ngalam");
  $dataPerPage = 5;

if(isset($_GET['page']))
{
    $noPage = $_GET['page'];
} 
else $noPage = 1;

$offset = ($noPage - 1) * $dataPerPage;


  $sql = "select * from produk LIMIT $offset, $dataPerPage";
  $hasil = mysql_query($sql);
  
  while($data=mysql_fetch_row($hasil)){
  echo "<tr>
		  <td>$data[2]</td>
		  <td>$data[3]</td>
		  <td>$data[4]</td>
		  </tr>";
		}
?>  
</table>
<strong><center><p><a href="home_adm.php">Halaman Admin &raquo; </a></p></center></strong>
</body>
</html>
